//
//  C_RankingCollectionViewCell.m
//  音悦咖
//
//  Created by Best on 15/7/15.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "C_RankingCollectionViewCell.h"


@implementation C_RankingCollectionViewCell

- (void)dealloc
{
    [_model release];
    [_titleLabel release];
    [_songListLabel release];
    [_placeLabel release];
    [_picView release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self create];
    }
    return self;
}


- (void)create
{
    
    self.picView = [[UIImageView alloc] init];
    [self addSubview:self.picView];
    [_picView release];
    
    
    self.titleLabel = [[UILabel alloc] init];
    [self addSubview:self.titleLabel];
    [_titleLabel release];
    
    
    self.placeLabel = [[UILabel alloc] init];
    [self addSubview:self.placeLabel];
    [_placeLabel release];
    
    
    self.songListLabel = [[UILabel alloc] init];
    [self addSubview:self.songListLabel];
    [_songListLabel release];
    
 
}


- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
{
    CGFloat width = layoutAttributes.frame.size.width;
    CGFloat height = layoutAttributes.frame.size.height;
    
    self.picView.frame = CGRectMake(10, 5,height - 10, height - 10);
    self.titleLabel.frame = CGRectMake(self.picView.frame.origin.x + self.picView.frame.size.width + 30, 0, width - (self.picView.frame.origin.x + self.picView.frame.size.width + 10) - 10, 30);
    self.titleLabel.textColor = WHITE;
    self.titleLabel.font = [UIFont systemFontOfSize:15];
   
    self.placeLabel.frame = CGRectMake(self.picView.frame.origin.x + self.picView.frame.size.width + 20, self.titleLabel.frame.size.height + self.titleLabel.frame.origin.y, width - (self.picView.frame.origin.x + self.picView.frame.size.width + 20) - 20, 2);
    self.placeLabel.textColor = WHITE;
    self.songListLabel.frame = CGRectMake(self.picView.frame.origin.x + self.picView.frame.size.width + 30, self.placeLabel.frame.origin.y + self.placeLabel.frame.size.height, width - (self.picView.frame.origin.x + self.picView.frame.size.width + 10) - 10, 20);
    self.songListLabel.textColor = WHITE;
}

- (void)setModel:(RankingListModel *)model
{
    if (_model != model) {
        [_model release];
        _model = [model retain];
    }
    [self.picView setImageWithURL:model.big_pic_url];
    self.titleLabel.text = model.title;
    self.placeLabel.text = @"----------------------------------";
    self.placeLabel.textColor = RGBA(180, 180, 180, 0.5);
    self.songListLabel.text = [NSString stringWithFormat:@"1.%@\n2.%@\n3.%@\n",[model.songlist[0] objectForKey:@"songName"], [model.songlist[1] objectForKey:@"songName"], [model.songlist[3] objectForKey:@"songName"]];
    
    
    
}


@end
